package com.sip.stream.utils.zfy;

import java.io.File;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.regex.Pattern;

public class ZFYMediaUtil {
    private final String TAG = "ZFYMediaUtil";

    public static final String SEP_PPI = "X";

    private final SimpleDateFormat DIRFORMAT = new SimpleDateFormat("yyyy-MM-dd");
    private final SimpleDateFormat FILEFORMAT = new SimpleDateFormat("yyyyMMddHHmmss");
    protected final String timeRege = "([2-3][0-9]{3})((0[1-9]|1[0-2]))(0[1-9]|[1-2][0-9]|3[0-1])([0-1][0-9]|2[0-3])([0-5][0-9])([0-5][0-9])";
    protected final Pattern fileNameTimePattern = Pattern.compile("([2-3][0-9]{3})((0[1-9]|1[0-2]))(0[1-9]|[1-2][0-9]|3[0-1])([0-1][0-9]|2[0-3])([0-5][0-9])([0-5][0-9])");

    public String getNewJpeg() {
        Date date = new Date(System.currentTimeMillis());
        String str = ZFYFilePath.getInstance().getAbsoluteFileDir("MEDIA_PHOTO") + this.DIRFORMAT.format(date);
        String str2 = ZFYUserInfo.defaultUserInfo().getUserCode() + this.FILEFORMAT.format(date) + ".jpg";
        File file = new File(str);
        if (file.exists() || file.mkdirs()) {
            return str + File.separator + str2;
        }
        return null;
    }

    public String getNewFileName() {
        return ZFYUserInfo.defaultUserInfo().getUserCode() + this.FILEFORMAT.format(new Date());
    }

    public String getNewFullPath(String str) {
        String str2 = ZFYFilePath.getInstance().getAbsoluteFileDir("MEDIA_PHOTO") + this.DIRFORMAT.format(new Date(System.currentTimeMillis()));
        File file = new File(str2);
        if (file.exists() || file.mkdirs()) {
            return str2 + File.separator + str;
        }
        return null;
    }

    public String getNewFullPath(String str, Date date) {
        String str2 = ZFYFilePath.getInstance().getAbsoluteFileDir("MEDIA_PHOTO") + this.DIRFORMAT.format(date);
        File file = new File(str2);
        if (file.exists() || file.mkdirs()) {
            return str2 + File.separator + str;
        }
        return null;
    }


    public SimpleDateFormat getDirFormate() {
        return this.DIRFORMAT;
    }
}
